package com.example.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;

import java.time.LocalDateTime;

/**
 * @description:
 * @author: zsw
 * @time: 2021/11/12 9:05
 */
public class CustomizeMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        LocalDateTime currentTime = LocalDateTime.now();
        this.strictInsertFill(metaObject, "createdAt", LocalDateTime.class, currentTime);
        this.strictInsertFill(metaObject, "updatedAt", LocalDateTime.class, currentTime);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        LocalDateTime currentTime = LocalDateTime.now();
        this.strictUpdateFill(metaObject, "updatedAt", LocalDateTime.class, currentTime);
    }
}